import 'package:drift/drift.dart';

import '../../entity/msg_constant.dart';
import 'act_tb.dart';
import 'base_table.dart';
import 'msg_tb.dart';
import 'user_tb.dart';

/// 会话
class SesTb extends Table with BaseTableMixin {
  ///登录账户id,用于数据隔离
  TextColumn get accountId => text().references(ActTb, #id)();

  ///唯一id
  TextColumn get id => text()();

  ///是否已删除
  BoolColumn get isDelete => boolean().clientDefault(() => false)();

  ///是否免打扰
  BoolColumn get isDotNotice => boolean().clientDefault(() => false)();

  ///是否置顶
  BoolColumn get isTop => boolean().clientDefault(() => false)();

  ///最后一条消息id
  IntColumn get lastMsgId => integer().nullable().references(MsgTb, #id)();

  @override
  Set<Column> get primaryKey => {id};

  ///会话类型
  TextColumn get sessionType => textEnum<SesType>()();

  ///未读消息数
  IntColumn get unReadNum => integer().clientDefault(() => 0)();

  ///关联用户信息
  TextColumn get userId => text().nullable().references(UserTb, #id)();

  ///是否可见
  BoolColumn get visible => boolean().clientDefault(() => true)();
}
